package com.workflow.workflowproject.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 *  表定义层。
 *
 * @author Administrator
 * @since 2024-10-28
 */
public class FlowFieldTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 
     */
    public static final FlowFieldTableDef FLOW_FIELD = new FlowFieldTableDef();

    /**
     * 字段id
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 是否存在
     */
    public final QueryColumn EXIST = new QueryColumn(this, "exist");

    /**
     * 标题
     */
    public final QueryColumn TITLE = new QueryColumn(this, "title");

    /**
     * 表单id
     */
    public final QueryColumn FORM_ID = new QueryColumn(this, "form_id");

    /**
     * 字段json
     */
    public final QueryColumn FIELD_JSON = new QueryColumn(this, "field_json");

    /**
     * 字段名称
     */
    public final QueryColumn FIELD_NAME = new QueryColumn(this, "field_name");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 修改时间
     */
    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, FIELD_NAME, TITLE, FIELD_JSON, FORM_ID, CREATE_TIME, UPDATE_TIME, EXIST};

    public FlowFieldTableDef() {
        super("", "t_com_flow_field");
    }

    private FlowFieldTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public FlowFieldTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new FlowFieldTableDef("", "t_com_flow_field", alias));
    }

}
